package com.xs.designs.duty_chain.temp;

import com.xs.designs.duty_chain.pojo.ProductDto;
import com.xs.designs.duty_chain.chain.IHandler;
import com.xs.designs.duty_chain.chain.ProductActivityHandler;
import com.xs.designs.duty_chain.chain.ProductBaseInfoHandler;
import com.xs.designs.duty_chain.chain.ProductSKUHandler;

public class ProductChainFactory {

    IHandler first;

    /**
     * 存放系统中责任链具体处理类
     * @param
     */
    public ProductChainFactory() {
        ProductBaseInfoHandler productBaseInfoHandler = new ProductBaseInfoHandler();
        ProductActivityHandler productActivityHandler = new ProductActivityHandler();
        ProductSKUHandler productSKUHandler = new ProductSKUHandler();
        productBaseInfoHandler.setNextHandler(productActivityHandler);
        productActivityHandler.setNextHandler(productSKUHandler);

        first=productBaseInfoHandler;
    }

    /**
     * 执行具体业务场景中的责任链集合
     */
    public void executeHandle(ProductDto productDto) {
        first.handle(productDto);
    }
}
